import React, { FC, useState } from "react"

const StateDemo2: FC = () => {
  const [person, setPerson] = useState({ name: "张三", age: 12 })
  const change = () => {
    setPerson({
      ...person,
      age: 13
    })
  }

  const [list, setList] = useState(["a", "b"])
  const changeList = () => {
    setList([...list, "c"])
  }
  return (
    <>
      <div onClick={change}>{JSON.stringify(person)}</div>
      <div onClick={changeList}>{JSON.stringify(list)}</div>
    </>
  )
}

export default StateDemo2
